package com.syq.day2;

import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;


/**
 * 构造器引用
 */
public class Sample3 {

    static class Student {
        public String name;
        public int age;
        public Student() {
            this.name = "小明";
            this.age = 18;
        }
        public Student(String name) {
            this.name = name;
            this.age = 20;
        }
        public Student(String name, int age) {
            this.name = name;
            this.age = age;
        }
        @Override
        public String toString() {
            return "Student{name='" + name + "', age=" + age + "}";
        }
    }

    public static void main(String[] args) {
        /**
         * 根据参数不同选择不同的函数式接口，也可以自己实现
         */
        Supplier<Student> s1 = Student::new;
        Function<String, Student> s2 = Student::new;
        BiFunction<String, Integer, Student> s3 = Student::new;
        System.out.println(s1.get());
        System.out.println(s2.apply("张三"));
        System.out.println(s3.apply("李斯", 19));
    }

}
